Error detection codes are used in all sorts of digital communication applications to enable the receiver of a message transmitted over a noisy channel to determine whether the message has been corrupted in transit. Before transmitting the message, the transmitter calculates an error detection code based on the message contents, and appends the code to the message. The receiver recalculates the code based on the message that it has received and compares it to the code appended by the transmitter. If the values do not match, the receiver determines that the message has been corrupted and, in most cases, discards the message.
Cyclic redundancy codes (CRCs) are one of the most commonly-used types of error correcting codes. To calculate the CRC of a message, a polynomial g(X) is chosen, having N+1 binary coefficients g0 . . . gN. The CRC is given by the remainder of the message, augmented by N zero bits, when divided by g(X). In other words, the CRC of an augmented message D(X) is simply D(X) mod g(X), i.e., the remainder of D(X) divided by g(X). There are many methods known in the art for efficient hardware and software implementation of CRC calculations. A useful survey of these methods is presented by Williams in “A Painless Guide to CRC Error Detection Algorithms” (Rocksoft Pty Ltd., Hazelwood Park, Australia, 1993), which is incorporated herein by reference.
CRCs are sometimes applied to more than one protocol of a data communications protocol stack. For example, in the protocol stack of the recently proposed Remote Direct Memory Access (RDMA) over Internet Protocol (IP) standard, CRCs are applied to both the Ethernet MAC and Marker PDU Aligned (MPA) protocols.
In high bandwidth systems, e.g., systems supporting 10 Gbps line rates, protocol stack processing may be resource-intensive for a host that interfaces with a communications network. Therefore, it is sometimes desirable for the host to offload a portion of the protocol stack processing to a network interface device (NID) that provides the host with an interface to the network. Protocols that are processed entirely by the NID are said to be “terminated” by the NID.
A drawback to such offloading is that the data transferred from the NID to the host may be corrupted by the NID and/or during transfer from the NID to the host. When the host does not terminate the data-intensive protocol or protocols that include the CRC calculation, the host is generally unable to detect such data corruption using methods known in the art. To overcome this drawback, it has been proposed that the NID calculate a CRC for the data to be transferred to the host. If the data has already been corrupted in the NID prior to calculation of the CRC, however, the CRC merely ensures accurate transmission of corrupted data to the host.
It has been demonstrated that data corruption by network hardware is a common occurrence. For example, Stone et al., in “When the CRC and TCP checksum disagree,” SIGCOMM 2000, pp. 309-319, studied nearly 500,000 IP packets which failed the Transport Control Protocol (TCP), User Datagram Protocol (UDP), or IP checksum. They write, “Probably the strongest message of this study is that the networking hardware is often trashing the packets which are entrusted to it.”
The above-mentioned U.S. patent application Publication 2003/0066011, to Oren, describes a method for error detection that includes receiving a block of data that is divided into a plurality of sub-blocks having respective offsets within the block, and processing the data in each of the sub-blocks so as to compute respective partial error detection codes for the sub-blocks. The partial error detection codes of the sub-blocks are modified responsively to the respective offsets, and the modified partial error detection codes are combined to determine a block error detection code for the block of data.